﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Quest
{
    class Ghost: Enemy
    {
        // enhancement #1: Make the enemies smarter
        private Dictionary<Levels, int> LevelsMaxDamage = new Dictionary<Levels, int>()
        {
            {Levels.Low, 3},
            {Levels.Medium, 4},
            {Levels.High, 5}
        };

        private static Dictionary<Levels, int> LevelsHitPoints = new Dictionary<Levels, int>()
        {
            {Levels.Low, 8},
            {Levels.Medium, 10},
            {Levels.High, 12}
        };
        private static Dictionary<Levels, int> LevelsMaxRandom = new Dictionary<Levels, int>()
        {
            {Levels.Low, 0},
            {Levels.Medium, 1},
            {Levels.High, 2}
        };


        // enhancement #1: Make the enemies smarter
        //public Ghost(Game game, Point point): base(game, point, 8)
        public Ghost(Game game, Point point, Levels level)
            : base(game, point, level, LevelsHitPoints[level])
        {
            maxDamage = LevelsMaxDamage[level];
        }

        // enhancement #1: Make the enemies smarter
        //private const int maxDamage = 3;
        private int maxDamage;

        public override void Move(Random random)
        {
            // Your code will go here
            Direction myDirection;
            int maxRandom = LevelsMaxRandom[level];// enhancement #1: Make the enemies smarter
            if (HitPoints > 0)
            {
                if (random.Next(3) <= maxRandom)// enhancement #1: Make the enemies smarter
                {
                    myDirection = FindPlayerDirection(game.PlayerLocation);
                    location = Move(myDirection, game.Boundaries);
                }

                if (NearPlayer())
                    game.HitPlayer(maxDamage, random);
            }
        }

    }
}
